package com.fly.simple.utils;

import java.util.Set;
import java.util.stream.Collectors;
import java.util.stream.Stream;

import org.apache.commons.lang3.StringUtils;

/**
 * 命令行结果解析工具
 */
public class LineParser
{
    public static String key(String line)
    {
        return StringUtils.substringBefore(line, " ");
    }
    
    public static Set<String> value(String line)
    {
        return Stream.of(StringUtils.substringAfter(line, " ").split(",")).map(p -> StringUtils.substringBetween(p, ":", "->")).filter(StringUtils::isNotBlank).map(p -> p.replace(":", "")).sorted().collect(Collectors.toSet());
    }
}
